package com.roy.sms.vo;

import java.util.Date;

import com.roy.sms.model.Article;
import com.roy.sms.util.DateUtil;

public class ArticleVO {
	private int id;
	private String title;
	private String content;
	private int columnId;
	private String columnName;
	private int authorId;
	private int authorName;
	private Date writeDate;
	private int state;
	private String writeDateStr;
	private String stateStr;
	private String hrefTitle;
	
	public ArticleVO(){
		
	}
	
	public ArticleVO(Article article){
		this.id = article.getId();
		this.title = article.getTitle();
		this.content = article.getContent();
		this.columnId = article.getColumn().getId();
		this.columnName = article.getColumn().getName();
		this.writeDate = article.getCreateDate();
		this.state = article.getState();
		setHrefTitle(article.getTitle());
		setWriteDateStr();
		setStateStr();
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public int getColumnId() {
		return columnId;
	}

	public void setColumnId(int columnId) {
		this.columnId = columnId;
	}

	public String getColumnName() {
		return columnName;
	}

	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	public int getAuthorId() {
		return authorId;
	}

	public void setAuthorId(int authorId) {
		this.authorId = authorId;
	}

	public int getAuthorName() {
		return authorName;
	}

	public void setAuthorName(int authorName) {
		this.authorName = authorName;
	}

	public Date getWriteDate() {
		return writeDate;
	}

	public void setWriteDate(Date writeDate) {
		this.writeDate = writeDate;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}
	
	public String getStateStr() {
		return stateStr;
	}
	
	public String getHrefTitle() {
		return hrefTitle;
	}

	public void setHrefTitle(String hrefTitle) {
		this.hrefTitle = "<a href='view.do?id="+id+"&edit=true'>"+title+"</a>";
	}

	public void setStateStr() {
		if(state == Article.STATE_PUBLISH){
			this.stateStr = "发布";
		} else {
			this.stateStr = "未发布";
		}
	}

	public String getWriteDateStr() {
		return writeDateStr;
	}

	public void setWriteDateStr() {
		this.writeDateStr = DateUtil.formatDate(writeDate, DateUtil.YYYYMMDDHHMM);
	}

	public Article getArticle() {
		Article article = new Article();
		article.setId(id);
		article.setTitle(title);
		article.setContent(content);
		article.setCreateDate(writeDate);
		article.setState(state);
		return article;
	}
}
